package com.bms.api.bussiness.member.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.bms.common.base.common.bean.Result;
import com.bms.common.base.common.component.OSSUtil;
import com.bms.common.base.web.BaseController;

import io.swagger.annotations.ApiOperation;

/**
 * 上传控制器
 * @author luowenliang <614169161@qq.com>
 * @since 2018/8/16 18:04
 */
@RestController
@RequestMapping("/upload")
public class UploadController extends BaseController{

	@Autowired
	private OSSUtil ossUtil;

    
	@ApiOperation("上传图片至OSS")
	@PostMapping("image")
	public Result updateImg(MultipartFile file,String floder){
		String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
		String imgUrl = ossUtil.saveImage(floder, suffix,(long) 777, file);
		return json(imgUrl);
	}

}
